<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="text" placeholder="请输入1-100之间的整数" id="i1">
<input type="button" value="猜一猜" onclick="f()"><br>
结果:<div id="d1"></div>
<script>
  let x = parseInt(Math.random() * 100) + 1;
  let count = 0;
  function f() {
    count++;
    if (i1.value > x) {
      d1.innerText = "大了";
    } else if (i1.value < x) {
      d1.innerText = "小了";
    } else {
      d1.innerText = "第"+count+"次猜对了";
    }

  }
</script>
</body>
</html>